-- ----------------------- SUMMARY -------------------------- --
-- this lua file saves all custom keymaps of neovim & plugins --
-- ---------------------------------------------------------- --

local opt = { noremap = true, silent = true }

-- ------------------ --
-- editor keybindings --

vim.keymap.set("n", "<ESC>", ":nohl<CR>", opt) -- cancel highlight
-- ------------------ --

-- ------------------ --
-- window keybindings --

-- new window
vim.keymap.set("n", "<leader>wh", ":sp<CR>",opt) -- create new window & 
vim.keymap.set("n", "<leader>wv", ":vsp<CR>",opt)
-- switch windows
vim.keymap.set("n", "<C-h>", "<C-w>h", opt) -- switch to left
vim.keymap.set("n", "<C-j>", "<C-w>j", opt) -- switch to below
vim.keymap.set("n", "<C-k>", "<C-w>k", opt) -- switch to upon
vim.keymap.set("n", "<C-l>", "<C-w>l", opt) -- switch to right

vim.keymap.set("n", "<C-y>", "<C-w>H",opt) -- make current window as full-high window and move it to left
vim.keymap.set("n", "<C-o>", "<C-w>L",opt) -- make current window as full-high window and move it to right
vim.keymap.set("n", "<C-u>", "<C-w>J",opt) -- make current window as full-width window and move it to bottom 
vim.keymap.set("n", "<C-i>", "<C-w>K",opt) -- make current window as full-width window and move it to top
-- switch buffer tabs
vim.keymap.set("n", "<A-j>", ":bn<CR>", opt) -- switch to previous
vim.keymap.set("n", "<A-k>", ":bp<CR>", opt) -- switch to next
vim.keymap.set("n", "<leader>gt", ":BufferLinePick<CR>",opt)
-- ------------------ --

-- --------------------- --
-- telescope keybindings --

local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, opt) -- search file by filename
vim.keymap.set("n", "<leader>fg", builtin.live_grep, opt)  -- search file by key words
-- --------------------- --

-- ------------------- --
-- neotree keybindings --

vim.keymap.set("n", "<leader>e", "<Cmd>Neotree reveal left toggle=true<CR>", opt) -- toggle neotree visibility
-- ------------------- --

-- --------------- --
-- lsp keybindings --

vim.keymap.set("n", "<leader>hh", vim.lsp.buf.hover, {})          -- hover help mesg
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, {})     -- go definition
vim.keymap.set("n", "<leader>gi", vim.lsp.buf.implementation, {}) -- go implementation
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {})    -- open code action
vim.keymap.set("n", "<leader>fb", vim.lsp.buf.format, {})         -- format the buf
-- --------------- --

-- --------------- --
-- dap keybindings --

local dap = require("dap")
local dapui = require("dapui")
vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint, opt)
vim.keymap.set("n", "<leader>dc", dap.continue, opt)
vim.keymap.set("n", "<leader>ds", dap.terminate, opt)
vim.keymap.set("n", "<leader>du", dap.step_over, opt)
vim.keymap.set("n", "<leader>di", dap.step_into, opt)
vim.keymap.set("n", "<leader>do", dap.step_out, opt)
vim.keymap.set("n", "<leader>dt", dapui.toggle, opt)
-- --------------- --

-- ---------------------- --
-- toggleterm keybindings --

vim.keymap.set("n", "<A-3>", "<Cmd>ToggleTerm<CR>", opt)
-- ---------------------- --

-- ----------------------- --
--  cmake-tool keybindings --
vim.keymap.set("n", "<leader>cb", "<Cmd>CMakeQuickBuild<CR>", opt)
vim.keymap.set("n", "<leader>cr", "<Cmd>CMakeQuickRun<CR>", opt)
vim.keymap.set("n", "<leader>cs", "<Cmd>CMakeQuickStart<CR>", opt)
vim.keymap.set("n", "<leader>cd", "<Cmd>CMakeQuickDebug<CR>", opt)
-- ----------------------- --

-- -------------------- --
-- overseer keybindings --

vim.keymap.set("n", "<leader>ot", "<Cmd>OverseerToggle<CR>", opt)
-- -------------------- --

